*****************************************************************
* Local Partisan Biases in Allocations of Foreign Aid: 
* A Study of Agricultural Assistance in India
*
* Brian Min, Eugenio Arima, David Backer, Allen Hicken, Ken Kollman, and Joel Selway 
* World Politics, 2023 no. 1
*
*
* DISTRICT-LEVEL ANALYSIS
* Replication code for: 
* Table 4 
* Appendix Tables 1, 2, 4
*
* Rev 7 July 2022
*****************************************************************



set more off 
clear all

use "DIST_India_AgAid_ts_full_20190724_v13.dta", clear
	gen c3_pct00=c3_pct*100
	gen c4_pct00=c4_pct*100

	
*******************************************
* TABLE 4 
* Explaining the Allocation of Agricultural Aid (Administrative-District Level)

	* Model 1
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m  i.year, fe

	* Model 2
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both l.align_ce l.align_st  l.electionyear l.turnout l.mov i.year, fe

	* Model 3
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both l.align_ce l.align_st l.electionyear l.turnout l.mov  l.bjp l.cp l.othp i.year, fe
		
		* To calculate marginal effects of key vars:
		margins, dydx(_all)

		margins, at(l.align_st=(0 1))
		margins, at(l.align_ce=(0 1))
		margins, at(l.align_both=(0 1))


					
*******************************************
* APPENDIX TABLE 1 
* Robustness Checks for Table 8 on Impacts of Agricultural Foreign Aid Projects on Cropland Coverage and Yields

use "DIST_India_AgAid_ts_full_20190724_v13.dta", clear
	gen c3_pct00=c3_pct*100
	gen c4_pct00=c4_pct*100

	* Drop duplicates of Junagadh District in Gujarat
duplicates drop adm2_name state year, force

* Merge in Crop data from Village Dynamics in South Asia (VDSA, 2015)
merge 1:1 adm2_name state year using "dt_area_prod_a_web.dta"
drop if _merge==2
drop _merge
merge 1:1 adm2_name state year using "dt_hyv_a_web.dta"
drop if distid==.

xtset distid year, yearly

	* Model 1
	xtreg c3_pct00 l.project_ongoing l.project_start l.SPI12m i.year, fe
	* Model 2
	xtreg c4_pct00 l.project_ongoing l.project_start l.SPI12m i.year, fe
	* Model 3
	xtreg CERL_TQ l.project_ongoing l.project_start l.SPI12m i.year, fe
	* Model 4
	xtreg PULS_TQ l.project_ongoing l.project_start l.SPI12m i.year, fe
	* Model 5
	xtreg c3_pct00 l.project_ongoing l.project_start l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year, fe
	* Model 6
	xtreg c4_pct00 l.project_ongoing l.project_start l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year, fe
	* Model 7
	xtreg CERL_TQ l.project_ongoing l.project_start l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year, fe
	* Model 8
	xtreg PULS_TQ l.project_ongoing l.project_start l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year, fe

		

*******************************************
* APPENDIX TABLE 2 
* Robustness Checks for Table 8 on Impacts of Agricultural Foreign Aid Projects on Cropland Coverage and Yields
* Five-year lag

	* Model 1
	xtreg c3_pct00 l5.project_ongoing l5.project_start l5.SPI12m i.year, fe
	* Model 2
	xtreg c4_pct00 l5.project_ongoing l5.project_start l5.SPI12m i.year, fe
	* Model 3
	xtreg CERL_TQ l5.project_ongoing l5.project_start l5.SPI12m i.year, fe
	* Model 4
	xtreg PULS_TQ l5.project_ongoing l5.project_start l5.SPI12m i.year, fe
	* Model 5
	xtreg c3_pct00 l5.project_ongoing l5.project_start l5.SPI12m l5.electionyear l5.turnout l5.mov l5.align_st l5.align_ce l5.align_both l5.bjp l5.cp l5.othp i.year, fe
	* Model 6
	xtreg c4_pct00 l5.project_ongoing l5.project_start l5.SPI12m l5.electionyear l5.turnout l5.mov l5.align_st l5.align_ce l5.align_both l5.bjp l5.cp l5.othp i.year, fe
	* Model 7
	xtreg CERL_TQ l5.project_ongoing l5.project_start l5.SPI12m l5.electionyear l5.turnout l5.mov l5.align_st l5.align_ce l5.align_both l5.bjp l5.cp l5.othp i.year, fe
	* Model 8
	xtreg PULS_TQ l5.project_ongoing l5.project_start l5.SPI12m l5.electionyear l5.turnout l5.mov l5.align_st l5.align_ce l5.align_both l5.bjp l5.cp l5.othp i.year, fe



*******************************************
* APPENDIX TABLE 4 
* District-Level Robustness Checks for Table 4
* Additional controls for literacy, female literacy, nighttime lights, drought-prone designation, and irrigated share of cropped area

	* DATA SOURCES: 
	* Drought-prone districts
		* http://old.cwc.gov.in/ISO_DATA_Bank/waterrelated2008/FINAL%20TABLES%20CH5-PDF/TABLE%205.03FINAL.pdf
	* Level of development 
		* District level (2011 census) control for literacy
	* Irrigated Share of Total Cropped Area 
		* https://aps.dac.gov.in/LUS/Public/Reports.aspx
		
use "DIST_India_AgAid_ts_full_20190724_v13.dta", clear
	gen c3_pct00=c3_pct*100
	gen c4_pct00=c4_pct*100
	
merge m:1 adm2_name state using "India_g2003_2_DPAP.dta"
drop _merge
merge m:1 adm2_name state using "DISTRICT_11stats.dta"
drop _merge
merge m:1 adm2_name state using "irrigated_districts_1998.dta"
drop _merge

xtset distid year, yearly
sort distid year

	* Convert population to millions
	replace tot_pop=tot_pop/1000000
	replace tot_pop=. if tot_pop==0	
	* Convert stable lights sum to log
	gen lnrstabsum=ln(rstabsum+1)
	replace lnrstabsum=. if lnrstabsum==0


	* Robustness checks using Random Effects

	* Model 1
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both i.year pct_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 2
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both i.year pct_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 3
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year pct_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 4
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both i.year pct_f_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 5
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both i.year pct_f_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 6
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year pct_f_lit tot_pop dist_area, re vce(cluster adm2_code)

	* Model 7
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both i.year dpap tot_pop dist_area, re vce(cluster adm2_code)

	* Model 8
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both i.year dpap tot_pop dist_area, re vce(cluster adm2_code)

	* Model 9
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year dpap tot_pop dist_area, re vce(cluster adm2_code)

	* Model 10
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both i.year shrcropirrig tot_pop dist_area, re vce(cluster adm2_code)

	* Model 11
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both i.year shrcropirrig tot_pop dist_area, re vce(cluster adm2_code)

	* Model 12
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year shrcropirrig tot_pop dist_area, re vce(cluster adm2_code)
	
	* Model 13
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.align_both i.year lnrstabsum tot_pop dist_area, re vce(cluster adm2_code)

	* Model 14
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both i.year lnrstabsum tot_pop dist_area, re vce(cluster adm2_code)

	* Model 15
	xtlogit project_start l.c3_pct l.c4_pct l.SPI12m l.electionyear l.turnout l.mov l.align_st l.align_ce l.align_both l.bjp l.cp l.othp i.year lnrstabsum tot_pop dist_area, re vce(cluster adm2_code)

	

	
	






